package com.nsoft.pdfrender;

public class PdfParagraph {
	public enum FontType{
		PLAIN,
		ITALIC,
		BOLD
	}
	public static int DEFAULT_FONTSIZE=15;
	
	private StringBuffer buff;
	private int fontSize;
	
	public int getFontSize() {
		return fontSize;
	}
	public void setFontSize(int fontSize) {
		this.fontSize = fontSize;
	}
	
	private FontType fontType;
	
	public FontType getFontType() {
		return fontType;
	}
	public void setFontType(FontType fontType) {
		this.fontType = fontType;
	}

	public PdfParagraph(){
		this.buff=new StringBuffer();
		setFontSize(DEFAULT_FONTSIZE);
		setFontType(FontType.PLAIN);
	}
	
	public String getText(){
		return buff.toString();
	}
	
	public String getHtml(){
		String html="<div style=\"margin-bottom:15px;";
		
		if (getFontSize()!=DEFAULT_FONTSIZE){
			html+="font-size:"+getFontSize()+"pt;";
		}
		html+="\" >";
		
		if (getFontType()==FontType.ITALIC){
			html+="<i>"+buff.toString()+"</i>";
		}else if (getFontType()==FontType.BOLD){
			html+="<b>"+buff.toString()+"</b>";
		}else{
			html+=buff.toString();
		}
		
		html+="</div>";
		
		return html;
	}
	
	public void append(String text){
		this.buff.append(text);
	}
}
